package com.apex.lottery.common.exception;

import com.apex.lottery.common.errorcode.ServiceErrorCodeConstants;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.apex.lottery.common.errorcode.ErrorCode;

/**
 * @ClassName ServiceException
 * @Description Service异常处理
 * @Author ZJX
 * @Date 2024/9/22 12:16
 * @Version 1.0
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class ServiceException extends RuntimeException{
    /**
     * 异常码
     *  @see ServiceErrorCodeConstants
     */
    private Integer code;

    private String message;

    public ServiceException(){

    }

    public ServiceException(Integer code,String message){
        this.code = code;
        this.message = message;
    }

    public ServiceException(ErrorCode errorCode){
        this.code = errorCode.getCode();
        this.message = errorCode.getMessage();
    }
}
